<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
<title>Document</title>
<link href="../assets/mobile/comm.css" rel="stylesheet" type="text/css" />
<link href="../assets/mobile/goods.css" rel="stylesheet" type="text/css" />
<link href="../assets/mobile/top.css" rel="stylesheet" type="text/css" />
<script src="../assets/js/mobile/jquery190.js" type="text/javascript"></script>
<link rel="stylesheet" href="../assets/agile/css/ratchet/css/ratchet.min.css">
<link rel="stylesheet" href="../assets/agile/css/flat/flat.component.css">
<link rel="stylesheet" href="../assets/agile/css/flat/iconline.css">
<link rel="stylesheet" href="../assets/app/css/app.css" />
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery.js"></script>
<script type="text/javascript" src="../script/config.js"></script>
<script type="text/javascript" src="../script/local.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script src="../assets/js/mobile/GoodsPicSlider.js" type="text/javascript"></script>
<script src="../assets/js/mobile/PeriodSlider.js" type="text/javascript"></script>
</head>
<body>
<!--通用顶部-->
<div id="ios-top-box">
    <div id="header" class="bar bar-nav">
    <div class="titlebar">
    <a href="javascript:appClose('f_item',api);"><i class="iconfont iconline-arrow-left"></i></a>
    <h1 class="title">商品详情</h1>
    </div>
    </div>
</div>
<!--通用顶部结束-->
<section class="scroller create_goods">
	
<!--轮播器开始-->		
      <div class="pPic pPicBor" style="padding:5px 0px;">
          <div class="pPic2">
  	        <div id="sliderBox" class="pImg">
                  <div class="comm-loading" style="background:#f4f4f4;"><em>正在加载</em></div>
                  <ul class="slides">
				<li><img class="lazy" data-original="" class="animClass" /></li>
                  </ul>
              </div>
          </div>
      </div>
<!--轮播器结束-->
   <ul class="listitem count_goods">
       <li>
       	<div class="text">
            <p><span class="jinxing"></span><font>加载中...</font></p>
           	<p><span class="money">市场价： ￥ 0.00</span></p>
			<p><span class="left">商城价：<font>加载中...</font></span></p>
		</div>
       </li>
    <li style="height:20px;line-height:20px;padding:0px 12px;color:#666;display:none;" class="goli1">夺宝要求：本特惠商品需您最少推荐注册<span></span>人</li>
	<li style="height:20px;line-height:20px;padding:0px 12px;color:#666;display:none;" class="goli2">公平夺宝：本特惠商品此时间最多可参与<span></span>人次</li>
	<li style="height:20px;line-height:20px;padding:0px 12px;color:#666;display:none;" class="goli3">逆袭夺宝：从未夺宝成功的用户可参与</li>
	<li style="height:20px;line-height:20px;padding:0px 12px;color:#666;display:none;" class="goli4">新手夺宝：注册<span></span>天内的新会员才能参与此商品夺宝</li>
       
   </ul>
		<form class="get_buy_form group_buy_form" style="border-bottom:1px dashed #eee;">
		<input type="hidden" value="" name="goods_id"/>
		<input type="hidden" value="" name="price"/>
		</form>
        <div class="joinAndGet">
			<ul class="table-view" style="border-bottom:0px;">
			  <li class="table-view-cell"  style="border-bottom:1px solid #ddd;font-size:13px;">
			    <a class="navigate-right" id="descs" href="javascript:;" style="font-size:13px;">图片详情</a>
			  </li>
			  <li class="table-view-cell"  style="border-bottom:1px solid #ddd;font-size:13px;">
			    <a class="navigate-right" id="buyrecord" href="javascript:;" style="font-size:13px;">所有抢购记录</a>
			  </li>
			  <li class="table-view-cell"  style="border-bottom:1px solid #ddd;font-size:13px;">
			    <a class="navigate-right opGoodspost" href="javascript:;" style="font-size:13px;">已有<span class="orange arial sunOrder">0</span>个幸运者晒单<strong class="orange arial sunOrderCount">0</strong>条评论</a>
			  </li>
			</ul>
		</div>
		
		<div class="detail-content" style="display:none;padding:0px 10px 10px 10px;overflow-x:hidden;">加载中...</div>
		<div class="block10"></div>
</section>
<div style="position:fixed;bottom:0px;width:100%;height:45px;background:#eee;">
	<button class="common-btn" id="z_addCart" style="width:95%;margin:5px auto 0 auto;font-size:20px;">立即免费抢购</button>
</div>
<input type="hidden" value="0" name="freeMax" id="freeMax" />
<script type="text/javascript">
apiready = function(){
	var func = "CommonClose('item');"
	api.execScript({
		name:'root',
		script:func
	});
	$(function(){
		var goods_id = localData.get('f_goods_id');
		if(!goods_id){
			api.alert({msg:'参数错误'});
			return;
		}
	  function loadscroller(){
	      $("#divPeriod").touchslider();
	      $("#sliderBox").picslider();
	  }
	  $('#buyrecord').click(function(){
	      openItem('buyrecord',goods_id,function(id){
		  	localData.set('goods_id',id);
		  });
	  });
	$('#descs').click(function(){
	      openItem('goodsdesc',goods_id,function(id){
		  	localData.set('goods_id',id);
		  });
	});
		GetJPData(config.url+'/app.php?act=f_item&goods_id='+goods_id,{},function(data){
			if(data['status'] == 1){
				$('.comm-loading').remove();
		        var imgs = '';
		        for(var i in data['item']['picarr']){
		            imgs += '<li><img src="'+config.upload_url+'/'+data['item']['picarr'][i]+'" class="animClass" /></li>';
		        }
		        if(data['item']['picarr'] == ''){
		            imgs += '<li><img src="'+config.upload_url+'/'+data['item']['thumb']+'" class="animClass" /></li>';
		        }
		        $('.pImg .slides').html(imgs);
		        loadscroller();
		        //str = data['item']['content'].replace(/src=/g,'class="lazy" data-original=');
		        //$('.detail-content').html(str);
		        //$('.detail-content img.lazy').lazyload({effect: "fadeIn"});
				var titlehtml = data['item']['title']+'<font style="'+data['item']['title_style']+'">'+data['item']['title2']+'</font>';
		        $('.jinxing').next().html(titlehtml);
		        $('.money').html('市场价：<del>￥'+data['item']['money']+'</del>');
		        $('p span.left font').text('0.00');
		        $('#freeMax').val(data['item']['freeMax']);
		        $('input[name=goods_id]').val(data['item']['id']);
		        $('input[name=price]').val(data['item']['yunjiage']);
				$('.goli1 span').text(data['item']['freeMin']);
				$('.goli2 span').text(data['item']['freeMax']);
				$('.goli1,.goli2').show();
        $('.sunOrderCount').text(data['sunOrder']['comment']);
        $('.sunOrder').text(data['sunOrder']['count']);
				if(data['item']['freetype'] == 0){
					$('.goli4 span').text(data['item']['registerDay']);
					$('.goli4').show();
				}else if(data['item']['freetype'] == 1){
					$('.goli3').show();
				}else if(data['item']['freetype'] == 2){
					
				}
		

	  $('.opGoodspost').click(function(){
	  	  openItem('goodspost',data['item']['sid'],function(sid){
		  	localData.set('goodsSid',data['item']['sid']);
		  });
	  });
				
		    	var goods_num = data['item']['zongrenshu'];
		    	if(goods_num <= 0){
		    		$('.common-btn').attr('id','fdasf').css('background','#999').text('缺货中...');
		    		return;
		    	}
		    	
		    	$('#z_addCart').click(function(){
		    		
		    		var userinfo = getUserinfo();
		    		if(!userinfo){
		    			api.alert({msg:'请登录用户'},function(index,err){
		    				api.openWin({name:'login','url':'./login.html',reload:true});
		    			});
		    			return;
		    		}else{
		    			//判断权限
		    			var goods_id = localData.get('f_goods_id');
		    			GetJPData(config.url+'/app.php?act=checkprosissim&uid='+userinfo.uid,{goods_id:goods_id},function(data){
		    				if(data['status'] == 1){
								localData.remove('f_cart');
								localData.remove('f_cart_num');
		    		    		var goods_id = $('input[name=goods_id]').val();
		    		    		var num = 1;
		    		    		var price = 0;
		    		    		var freeMax = $('#freeMax').val();
		    		    		f_addCart(goods_id,price,num,'add',parseInt(freeMax));
		    	    			setTimeout(function(){
		    	    				api.openWin({name:'f_cart','url':'./f_cart.html',reload:true});
		    	    			},1500);
		    				}else{
		    					api.alert({msg:data['msg']},function(index,err){});
		    				}
		    			});
		    		}
		    		return false;
		    	});
		        
			}else{
				api.alert({title:'',msg:data['msg']});
			}
		});
		
	});
};
</script>
</body>
</html>